home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SPX30.ZIP / SPX_DOC.ZIP / SPX_VSP.DOC < prev    next >
Encoding:
Text File  |  1994-06-13  |  8.9 KB  |  256 lines

  1. { SPX Library Version 3.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.  SPX_VSP unit contains majority of the sprite manipulation routines.
  4.  
  5. ───────────────────────────────────────────────────────────────────────────
  6. function pointvsp(x,y:integer;var buff):byte;
  7.    returns the pixel value within a sprite.
  8.  
  9.    x,y :  offset into the sprite
  10.  
  11. ───────────────────────────────────────────────────────────────────────────
  12. procedure psetvsp(x,y:integer;c:byte;var buff);
  13.  
  14.   Sets the pixel value in a sprite
  15.  
  16.   x,y : offset into the sprite
  17.   c  : color to place
  18.  
  19. ───────────────────────────────────────────────────────────────────────────
  20. procedure MatteVsp(var from,too);
  21.  
  22.   Create a matte for a sprite file.  Uses the SET thdmat to determine
  23.   which colors will be transparent.
  24.  
  25.   FROM: Sprite to convert;
  26.   TOO:  Created masked sprite
  27.  
  28.   NOTE:  The buffer "too" must be pre-allocated.
  29.  
  30.  
  31. ───────────────────────────────────────────────────────────────────────────
  32. procedure fget(x1,y1,x2,y2:integer;var image);
  33.   Grabs a sprite from the active page.
  34.  
  35.   X1,Y1:  Coordinate one of the region;
  36.   X2,Y2:  Coordinate two of the region;
  37.   IMAGE:  Sprite to create
  38.  
  39.   NOTE:  IMAGE must be pre-allocated
  40.  
  41. ───────────────────────────────────────────────────────────────────────────
  42. procedure ScaleVSP(var src,dest;nx,ny:word);
  43.  
  44.   Stretches or shrinks a sprite to a new size.
  45.  
  46.   SRC:    Sprite to scale;
  47.   DEST:   New sprite scaled;
  48.   NX,NY:  Width and Height of the new sprite
  49.  
  50.   NOTE:  DEST must be preallocated.
  51.  
  52.   EXAMPLE:
  53.  
  54.   var
  55.     MySprite,
  56.     NewSize  : pointer;
  57.  
  58.        .
  59.        .
  60.        .
  61.     getmem(NewSize,buffsize(16,16));
  62.     ScaleVSP(MySprite^,NewSize^,16,16);  { Changes MySprite to be size 16x16 }
  63.  
  64.  
  65. ───────────────────────────────────────────────────────────────────────────
  66. procedure fput(x1,y1:integer;var image;center:boolean);
  67.  
  68.   Displays a sprite on the active page.
  69.  
  70.   X1,Y1:  Coordinate to place top-left of sprite.  If CENTER is TRUE
  71.           X1,Y1 is the coordinate of the center of the sprite;
  72.   IMAGE:  Sprite;
  73.   CENTER: Set to TRUE to display sprite centered on X1,Y1
  74.  
  75. ───────────────────────────────────────────────────────────────────────────
  76. procedure fput_clip(x,y:integer;var buff;center:boolean);
  77.  
  78.   Displays a sprite on the active page. Clips the sprite according
  79.    to WinMinX, WinMinY, WinMaxX, WinMaxY.
  80.  
  81.   X,Y:    Coordinate to place top-left of sprite.  If CENTER is TRUE
  82.           X,Y is the coordinate of the center of the sprite;
  83.   buff:   Sprite;
  84.   CENTER: Set to TRUE to display sprite centered on X,Y
  85.  
  86. ───────────────────────────────────────────────────────────────────────────
  87. procedure fput_mask(x1,y1:integer;var image;rmw:byte);
  88.  
  89.   Displays a sprite on the active page.
  90.  
  91.   X1,Y1:  Coordinate to place top-left of sprite.
  92.   IMAGE:  Sprite;
  93.   RMW:    Type of display method
  94.  
  95.           CopyPut      : Use normal copy. (fput recommened instead)
  96.           XORPut       : XOR the sprite with the active display
  97.           OrPut        : OR the sprite with the active display
  98.           AndPut       : AND the sprite with the active display
  99.  
  100. ───────────────────────────────────────────────────────────────────────────
  101. procedure ftput(x,y:integer;var buff;center:boolean);
  102.  
  103.   Displays a sprite on the active page with color 0 as a transparent
  104.   color.  Does NOT preform any clipping.
  105.  
  106.   X,Y:    Coordinate to display top-left of sprite.  If CENTER is TRUE
  107.           X,Y is the coordinate of the center of the sprite;
  108.   BUFF:   Sprite;
  109.   CENTER: Set to TRUE to display sprite centered on X,Y
  110.  
  111. ───────────────────────────────────────────────────────────────────────────
  112. procedure ftput_clip(x,y:integer;var buff;center:boolean);
  113.  
  114.   Displays a sprite on the active page with color 0 as a transparent
  115.   color.  Clips the sprite according to WinMinX, WinMinY, WinMaxX, WinMaxY.
  116.  
  117.   X,Y:    Coordinate to place top-left of sprite.  If CENTER is TRUE
  118.           X,Y is the coordinate of the center of the sprite;
  119.   BUFF:   Sprite;
  120.   CENTER: Set to TRUE to display sprite centered on X,Y
  121.  
  122.  
  123. ───────────────────────────────────────────────────────────────────────────
  124. procedure ftput_clip_mask(x,y:integer;var buff;center:boolean;var virt);
  125.  
  126.    Displays a sprite on the active page with color 0 as a transparent
  127.    color.  Clips the sprite according to WinMinX, WinMinY, WinMaxX, WinMaxY.
  128.    also checks the 320x200 virtual page as a mask.
  129.  
  130.    For this function to draw a pixel from a sprite the following must be true:
  131.  
  132.       sprite pixel must be non-zero
  133.       pixel must be in the bounds of the clipped region
  134.       the correspoding coordinate on the virtual page must be non-zero
  135.  
  136. ───────────────────────────────────────────────────────────────────────────
  137. procedure fctput_clip(x,y:integer;var buff;center:boolean;color:byte);
  138.  
  139.    Displays a sprite on the active page with color 0 as a transparent
  140.    color.  Clips the sprite according to WinMinX, WinMinY, WinMaxX, WinMaxY.
  141.    Displays all non-zero pixels to (color).
  142.  
  143. ───────────────────────────────────────────────────────────────────────────
  144. procedure fxtput_clip(x,y:integer;var buff;center:boolean;var table);
  145.  
  146.    Displays a sprite on the active page with color 0 as a transparent
  147.    color.  Clips the sprite according to WinMinX, WinMinY, WinMaxX, WinMaxY.
  148.    Using a look up table for the sprite.
  149.  
  150.    table: must be of size 256 bytes:  { array[0..255] of byte }
  151.  
  152.    The sprite pixel color becomes an index to the table.  The value in the
  153.    table becomes the color displayed.
  154.  
  155.    e.g.
  156.  
  157.    var
  158.      i : integer;
  159.      table : array[0..255] of byte;
  160.    begin
  161.       for i := 0 to 255 do
  162.         table[i] := i;
  163.       table[40] := 2;
  164.  
  165.       fxtput_clip(100,100,sprite^,true,table);
  166.    end;
  167.  
  168.    The above example will display the sprite centered at (100,100).
  169.    All the colors of the sprite will be the same except for color 40
  170.    will be displayed as color 2.
  171.  
  172. ───────────────────────────────────────────────────────────────────────────
  173. procedure displayer(x,y:integer;var pic,virt;plv:byte);
  174.  
  175.    Displays a Sprite (pic) on the current page. Based on the sprite's level
  176.    (plv).  The (virt) is the virtual page that keeps track of all of the
  177.    sprites currently on the screen.
  178.  
  179.    Think of the display having 256 layers.  Layer 0 is furthest back and
  180.     layer 255 is the top layer.  For example, a sprite "Displayer" with
  181.     plv=4 will only overwrite sprites that have been written with a plv
  182.     value less than 4.  Sprites greater than 4 will be unaffected.
  183.  
  184.    The how DispLayer works:
  185.       Functions the same as ftput, except that it also checks the
  186.       screen location on the "virt" page.  If that pixel value is less
  187.       than the "plv" value, then the pixel is drawn.
  188.  
  189.    Use the "DispLayer" function with DispVirt to update the virtual page.
  190.  
  191.  
  192.    X,Y:   Top-left position of sprite;
  193.    PIC:   Sprite to display;
  194.    VIRT:  Virtual page for sprite levels;
  195.    PLV:   Sprite level value
  196.  
  197. ───────────────────────────────────────────────────────────────────────────
  198. procedure eraselayer(x,y:integer;bkpage:byte;var pic,virt;plv:byte);
  199.  
  200.    Erases a sprite on the current page.
  201.  
  202.    X,Y:    Coordinates to place the sprite;
  203.    BKPAGE: Backgroun page to write to the current screen;
  204.    PIC:    Sprite to erase;
  205.    VIRT:   Virtual page for sprite levels;
  206.    PLV:    Sprite level value
  207.  
  208.    Erases each sprite pixel when the byte on the (virt) page is
  209.    less than or equal to (plv).
  210.  
  211. ───────────────────────────────────────────────────────────────────────────
  212. procedure dispvirt(x,y:integer;var pic,virt;plv:byte);
  213.  
  214.    Updates the virtual page with the sprite level value.
  215.  
  216.    X,Y:  Coordinates of the sprite;
  217.    PIC:  Sprite to update;
  218.    VIRT: Virtual page to be updated;
  219.    PLV:  Sprite level value
  220.  
  221. ───────────────────────────────────────────────────────────────────────────
  222. procedure displayer_clip(x,y:integer;var pic,virt;plv:byte);
  223.  
  224.   Same as the procedure displayer but clips according to
  225.   WinMinX, WinMinY, WinMaxX, WinMaxY.
  226.  
  227. ───────────────────────────────────────────────────────────────────────────
  228. procedure dispvirt_clip(x,y:integer;var pic,virt;plv:byte);
  229.  
  230.    Same as the procedure dispvirt but clips according to
  231.   WinMinX, WinMinY, WinMaxX, WinMaxY.
  232.  
  233. ───────────────────────────────────────────────────────────────────────────
  234. procedure erasevirt(x,y:integer;var pic,virt;plv:byte);
  235.  
  236.    Erases the virtual page with the sprite level value.
  237.  
  238.    X,Y:  Coordinates of the sprite;
  239.    PIC:  Sprite to update;
  240.    VIRT: Virtual page to be erased;
  241.    PLV:  Sprite level value
  242.  
  243.  
  244. ───────────────────────────────────────────────────────────────────────────
  245. procedure copyvirt(x,y:integer;var pic,v1,v2;plv:byte);
  246.  
  247.    Copies a virtual area to another virtual page
  248.  
  249.    X,Y:  Coordinates of the sprite;
  250.    PIC:  Sprite to update;
  251.    V1:   Virtual page source;
  252.    V1:   Virtual page destination;
  253.    PLV:  Sprite level value
  254. ───────────────────────────────────────────────────────────────────────────
  255.  
  256.